{extend name="Public:base"/}

{block name="main"}
<div class="box-info">
    <form id="myform" name="myform" action="{:U('Category/add')}" method="post">

        <div class="form-group row">
            <label class="col-md-2 text-right">上级栏目</label>
            <div class="col-md-5">
                <select name="parentid" class="form-control" <?php if($data['parentid'] == 0):?>disabled<?php endif;?>>
                <option value="0">作为一级栏目</option>
                {$select_categorys}
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label class="col-md-2 text-right">栏目名称</label>
            <div class="col-md-5">
                <input type="text" name="catname" class="form-control" value="{$data['catname']}" />
            </div>
        </div>
        <div class="form-group row">
            <label class="col-md-2 text-right">英文栏目名称</label>
            <div class="col-md-5">
                <input type="text" name="wap_catname" class="form-control" value="{$data['wap_catname']}" />
            </div>
        </div>
        <div class="form-group row" id="model_url">
            <label class="col-md-2 text-right">链接地址</label>
            <div class="col-md-5">
                <input type="text" name="url" class="form-control" value="{if condition="$data['type']==2"}{$data['url']}{/if}" />
            </div>
        </div>
        <div class="form-group row">
            <label class="col-md-2 text-right">栏目图片</label>
            <div class="col-md-5">
                <div class="thumb_image">
                    <div id="image_aid_box"></div>
                    <a class="thumbnail" href="javascript:swfupload('image','{:get_auth(1,'1048576',1)}',yesdo);">
                        <img id="image_pic" height="68" src="{if condition="!empty($data['image'])"}{$data['image']}{else/}__IMG__/upload_thumb.png{/if}"></a>
                    <input type="button" value="取消图片" onclick="javascript:clean_thumb('image');" class="btn btn-sm btn-primary"/>
                    <input type="hidden" id="image" name="image" value="{$data['image']}"/>
                </div>
            </div>
        </div>

        <div class="form-group row" >
            <label class="col-md-2 text-right">pc导航</label>
            <div class="col-md-5">
                {:Form::radio(array('field'=>'ismenu','options'=>array('1'=>'是','0'=>'否')), $data['ismenu'])}
            </div>
        </div>
        <div class="form-group row" >
            <label class="col-md-2 text-right">wap导航</label>
            <div class="col-md-5">
                {:Form::radio(array('field'=>'is_wap_menu','options'=>array('1'=>'是','0'=>'否')), $data['is_wap_menu'])}
            </div>
        </div>
        <div class="form-group row" >
            <label class="col-md-2 text-right">新窗口打开</label>
            <div class="col-md-5">
                {:Form::radio(array('field'=>'isblank','options'=>array('1'=>'是','0'=>'否')), $data['isblank'])}
            </div>
        </div>

        <div class="form-actions">
            <input type="hidden" name="type" value="2">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-danger" onclick="javascript:history.back(-1);return false;">返回</button>
        </div>
    </form>
</div>

{/block}

{block name="script"}

<script type="text/javascript">
    $(document).ready(function() {
        $('#myform').ajaxForm({
            success:  complete,  // post-submit callback
            dataType: 'json'
        });
    });

    function complete(data){
        if(data.status==1){
            layer.msg(data.info, {
                icon: 1,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function(){
                window.location.href = "{$Think.cookie.__forward__}";
                return true;
            });
        }else{
            layer.msg(data.info, {
                icon: 2,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
        }

    }

    function urlrule(m){
        if(m==1){
            $('#urlrule').show();
        }else{
            $('#urlrule').hide();
        }
    }

    urlrule({$data['ishtml']});

</script>
{/block}